package org.example;

import org.example.directExchange.MessageSender;
import org.example.topicExchange.NewsProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;

/**
 * @author xuan
 * @create 2024/4/25
 */
@SpringBootApplication
public class Application implements CommandLineRunner {
    @Autowired
    private MessageSender messageSender;

    @Autowired
    private NewsProducer newsProducer;

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        //messageSender.sendMessage("test.exchange", "test.routingKey", "Hello, RabbitMQ!");
        newsProducer.sendNews("entertainment", "我是娱乐新闻！");
    }
}
